A kernel is a core of an operating system responsible for managing the system process, memory, device driver, file, network system and so on, and determines the performance and stability of the system. A method of realizing kernel patching by, for example, replacing the kernel and restarting the system fails to meet the high reliability requirements of carrier-class products. As such, a patching technology capable of immediately upgrading the kernel function of the operating system during the operation of the kernel is needed. In an existing kernel hot patching technology, the kernel function is renovated in the form of a memory patch during the operation of the kernel instead of replacing the whole kernel, thereby improving the system reliability. Therefore, the kernel hot patching technology has been widely applied in renovating the kernel function of the operating system in the carrier-class products.
A prior art technique based on the kernel hot patching technology is implemented as follows. Two source codes (including a source code before the modification of a kernel and a patch source code after the modification of the kernel) are compiled, and all object files in the compiled two source codes are compared with each other to determine an object file that is different among the two source codes. The determined object file is then connected to a script file for realizing an auto-loading function (e.g. ksplice kernel module) to generate a patch package file that can be identified by a Linux system and has an auto-loading function. Afterwards, the Linux system is restarted, and the patch package file is triggered by an external control command (e.g. insmod command) to be auto-loaded to the Linux system and become valid automatically. In the patch validation process, a stop_machine_run system function of the Linux system is employed to create a non-interrupted thread with the highest priority for each CPU in the system. Then, call stacks of all the created threads in the system are checked to see whether a primitive function of the kernel that has the same name as the patch function defined in the patch package file is executed in the system. If not, the primitive function is replaced by the patch function. Otherwise, the non-interrupted thread with the highest priority running on each CPU is exited, and the functions executed in the created threads are checked again after a period of time elapsed. If the repeated checking times exceeds a preset number, the kernel patching fails.
During the kernel hot patching in the prior art, the operation of all the other threads in the system is interrupted, and the normal operation of the operating system is seriously affected, thereby detracting from high reliability requirements of the carrier-class products.